<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计算三个数字并从小到大排序</title>
</head>
<body>
    <script>
        function sorting(){
            //假设第一个数为最大最小值
            var min = arguments[0];
            var cen;
            var max = arguments[0];

            for(var i=0;i<arguments.length;i++){
                //对比确定最小值
                if(min > arguments[i]){
                    min = arguments[i];
                }
                //对比确定最大值
                if(max < arguments[i]){
                    max = arguments[i];
                }
            }
            
            //剩下的值为中间值
            for(var j=0;j<arguments.length;j++){
                if(arguments[j] !== min && arguments[j] !== max){
                    cen = arguments[j];
                }
            }
            console.log(min,cen,max);
        }

        sorting(111,21,324);
    </script>
</body>
</html>